import urllib3
import httpx
import subprocess

#http = urllib3.PoolManager()
def save_ts(url,filePath):
    headers = {
        "Accept":"*/*",
        "Accept-Encoding":"gzip, deflate, br",
        "Accept-Language":'"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
        "Cache-Control":"no-cache",
        "Origin":"https://v.youku.com",
        "Pragma":"no-cache",
        "Referer":"https://v.youku.com/v_show/id_XMTc5NTY4MDQ4.html?playMode=pugv&frommaciku=1",
        "Sec-Ch-Ua":'"Not.A/Brand";v="8", "Chromium";v="114", "Microsoft Edge";v="114"',
        "Sec-Ch-Ua-Mobile":"?0",
        "Sec-Ch-Ua-Platform":"Windows",
        "Sec-Fetch-Dest":"empty",
        "Sec-Fetch-Mode":"cors",
        "Sec-Fetch-Site":"cross-site",
        "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82"
    }
    header = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82"}
    #res = http.request("GET",url,headers=headers).data
    res = httpx.get(url=url,headers=header,timeout=10,verify=False)
    with open(filePath,"wb") as f:
        for chunk in res.iter_bytes():
            f.write(chunk)
#调用ffmpeg的函数
def call_ffmpeg(command):
    subprocess.call(command,shell=True)